package com.ys.data.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.common.pojo.Result;
import com.common.util.DingDingUtils;
import com.common.util.RedisUtil;
import com.common.vo.dd.DingDingTextVo;
import com.common.vo.OrderVo;
import com.ys.data.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.ys.data.entry.Order;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import javax.annotation.Resource;

@Api(value = "订单相关API")
@RestController
@RequestMapping("order")
public class OrderController {

    @Resource
    private OrderService orderService;
    @Resource
    private RedisUtil redisUtil;

    @Resource
    private JedisPool jedisPool;

    @ApiOperation(value = "查询订单详情信息",notes = "查询")
    @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "Long")
    @PostMapping("find")
    public Result<?> findOrderById(@RequestParam Long id) throws Exception {
        Result result = new Result();
        result.OK(orderService.findOrderById(id));
        return result;
    }

    @ApiOperation(value = "分页查询订单列表",notes = "列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", paramType = "query",required = true, dataType = "int"),
            @ApiImplicitParam(name = "pageSize",value = "条数",paramType = "query",required = true,dataType = "int"),
    })
    @PostMapping("page")
    public Result<?> orderPage(@RequestBody OrderVo orderVo,
                                  @RequestParam(value = "pageNum") int pageNum,
                                  @RequestParam(value = "pageSize")  int pageSize) throws Exception {
        Result result = new Result();
        Page<Order> page = new Page<>(pageNum,pageSize);
        result.OK(orderService.orderPage(page,orderVo));
        return result;
    }

}
